<?php
class ReportDao extends BaseDao
{
	private $tgReport;
	
	public function __construct()
	{
		parent::__construct();
		$this->tgReport 	= $this->db->getTDG(C('LtConfig')->get('db.table.prefix')."report");
	}
	
	public function get($id)
	{
		return $this->tgReport->fetch($id);
	}
	
	public function add($data)
	{
		$result = $this->tgReport->insert($data);
		return $result;
	}
	
	public function count($condition)
	{
		$result = $this->tgReport->count($condition);
		return $result;
	}
	
	public function fetchRows($condition)
	{
		$result = $this->tgReport->fetchRows($condition);
		return $result;
	}
	
	public function exists($tradeId,$numIid)
	{
		$condition['where']['expression'] 			= "trade_id=:trade_id and num_iid=:num_iid";
		$condition['where']['value']['trade_id'] 	= $tradeId;
		$condition['where']['value']['num_iid'] 	= $numIid;
		$tmp	= array();
		$tmp 	= $this->tgReport->fetchRows($condition);
		$result = $tmp ? true : false; 
		return $result;
	}
}